package com.bdqn.ch03.SL;

import com.bdqn.ch03.mapper.NewsDao;
import com.bdqn.ch03.pojo.AbstractFactory;
import com.bdqn.ch03.pojo.MySqlDaoFactory;
import com.bdqn.ch03.pojo.News;
import com.bdqn.ch03.service.impl.NewsServiceImpl;

/**
 * NewsServiceImplTest
 *
 * @aurhor Administrator  whs
 * @since 2024/7/1
 */
public class NewsServiceImplTest {

    public void addNews() throws Exception{
    //    NewsDao dao = SimpleDaoFactory.getInstance("mysql");
    //    NewsServiceImpl service = new NewsServiceImpl();
        //示例5 改变具体工厂可创建不同产品
        AbstractFactory factory = new MySqlDaoFactory();
        NewsDao dao = factory.getInstance();
        NewsServiceImpl service  = new NewsServiceImpl();
        service.setDao(dao);

        News news = new News();
        news.setnTitle("测试标题3");
        news.setnContent("测试内容4");
        service.addNews(news);


//        News news = new News();
//        news.setnTitle("测试标题2");
//        news.setnContent("测试内容2");
//        service.addNews(news);
    }
}
